﻿package fwk.utiles.colorFilters
{
	import flash.display.MovieClip;
	import flash.filters.ColorMatrixFilter;
	
	

	// Black and White filter 
	public class BWFilter 
	{
		
		public static function apply(clip:MovieClip, cancel:Boolean = false)
		{
			
			if(!cancel){
				var scale = 1.2;
				var luminosite = - 300;
				 
				var a = new Array();
				 
				a = a.concat([scale, scale, scale, 0, luminosite]);
				a = a.concat([scale, scale, scale, 0, luminosite]);
				a = a.concat([scale, scale, scale, 0, luminosite]);
				a = a.concat([0, 0, 0, 1, 0]);
				 
				var filtre:ColorMatrixFilter = new ColorMatrixFilter(a);
				clip.filters = [filtre];

			}else {
				clip.filters = null;
			}
			
			
		}
		
		/**
		 * return a Black and white ColorMatrixFilter
		 * @return a ColorMatrixFilter
		 */
		public static function getFilter():ColorMatrixFilter
		{
			var scale = 1.2;
			var luminosite = - 300;
			 
			var a = new Array();
			 
			a = a.concat([scale, scale, scale, 0, luminosite]);
			a = a.concat([scale, scale, scale, 0, luminosite]);
			a = a.concat([scale, scale, scale, 0, luminosite]);
			a = a.concat([0, 0, 0, 1, 0]);
			
			var filtre:ColorMatrixFilter = new ColorMatrixFilter(a);
				
			return  filtre;
		}
		
	
	}
	
	
}